<template>
	<div class="header">
		<el-menu class="el-menu-demo" mode="horizontal" @select="handleSelect" active-text-color="rgba(0,0,0,0)" background-color="rgba(0,0,0,0)" default-active="red">
			<div class="cashlogo">
				<div>趣收银</div>
			</div>
			<div class="navbtn">
				<li>{{username}}</li>
				<li>
					<a href="https://h5.qudaox.com/pages/business/blogin/blogin.html" style="color: white;text-decoration:none;font-size:14px ;" target="_blank">商铺后台</a>
				</li>
				<li v-on:click="clearcookicefun()">登出</li>
				<li>
					<el-dropdown>
						<span class="el-dropdown-link" style="font-size: 14px;color: white;display: inline-block;height: 100%;">
        						更多<i class="el-icon-arrow-down el-icon--right"></i>
      						</span>
						<el-dropdown-menu slot="dropdown">
							<li class="nav_lis" v-on:click="startorder(1)">开单</li>
							<li class="nav_lis" v-on:click="findorder(1)">查单</li>
						</el-dropdown-menu>
					</el-dropdown>
				</li>
			</div>
		</el-menu>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				username:''
			};
		},
		mounted() {
			this.onload();
		},
		methods: {
			onload: function() {
				this.username = this.getCookie("username");
			},
			handleSelect(key, keyPath) {
				console.log(key, keyPath);
			},
			//点击选中
			handleCurrentChange(val) {
				console.log(val)
				this.currentRow = val;
			},
			//退出登录
			clearcookicefun(){
				this.clearCookie("uin");
				this.clearCookie("token");
				this.clearCookie("guadanarr");
				this.clearCookie("order_sn");
				this.clearCookie("shop_id");
				this.clearCookie("shop_name");
				this.clearCookie("username");
				this.$router.push({
					path: '/pages/login'
				})
			},
			//查单
			findorder: function(type){
				//type == 0 商品加入挂单列表  type == 1 查看挂单列表
				//将订单json 存入 挂单列表
				if(type == 0){
					
				}else{
					this.$router.push({ path: '/pages/orderlist' })
				}
			},
			//挂单
			restingorder: function(type){
				console.log(type);
				//type == 0 商品加入挂单列表  type == 1 查看挂单列表
				//将订单json 存入 挂单列表
				if(type == 0){
					
				}else{
					this.$router.push({ path: '/pages/restingorder' })
				}
			},
			startorder: function(type){
				if(type == 0){
					
				}else{
					this.$router.push({ path: '/' })
				}
			},
			setCookie: function(c_name, c_pwd, exdays) {
				var exdate = new Date(); //获取时间
				exdate.setTime(exdate.getTime() + 60 * 60 * 1000 * exdays); //小时
				//字符串拼接cookie
				//				window.document.cookie = "uin" + "=" + c_pwd + ";path=/;expires=" + exdate.toGMTString();
				//				window.document.cookie = c_name + "=" + c_pwd + "; " + exdate.toGMTString();
				document.cookie = c_name + ("=" + (c_pwd) + ";expires=" + exdate.toGMTString() + ";path=/;");
			},
			//清除cookie
			clearCookie: function(name) {
				this.setCookie(name, "", -1); //修改2值都为空，天数为负1天就好了
			},
			//读取cookie
			getCookie: function(cname) {
				var name = cname + "=";
				var ca = document.cookie.split(';');
				for(var i = 0; i < ca.length; i++) {
					var c = ca[i];
					while(c.charAt(0) == ' ') c = c.substring(1);
					if(c.indexOf(name) != -1) return c.substring(name.length, c.length);
				}
				return "";
			}
		}
	}	
</script>

<style>

</style>